#include<stdio.h>
#include<string.h>
struct Node
{
    int x, y, step;     
};
char ins1[3], ins2[3];
int sx, sy, ex, ey;
Node queue[70];
int movex[]={1,1, -1,-1,2,-2,2,-2};
int movey[]={2,-2, 2,-2,1,1,-1,-1};
int flag[9][9];

void bfs()
{
     int head = 0, tail = 1, i, answer;
     Node now, next;
     now.x = sx;
     now.y = sy;
     now.step = 0;
     queue[head] = now;
     
     while(tail > head)
     {
         now = queue[head];
         head ++;
         if(now.x == ex && now.y == ey)
                  {
                        answer = now.step;
                        break;
                  }
         for(i = 0; i< 8; i++)
         {
               next.x = now.x + movex[i];
               next.y = now.y + movey[i];
               next.step = now.step + 1;
               if(next.x >= 1 && next.x <= 8 
               && next.y >= 1 && next.y <= 8 
               && flag[next.x][next.y] == 0 )
               
               {
                       queue[tail] = next;
                       tail ++;
                       flag[next.x][next.y] = 1;
               }
         }
     }
     printf("To get from %s to %s takes %d knight moves.\n", ins1, ins2, answer);
}

int main()
{
    while(1)
    {
            if(scanf("%s %s", ins1, ins2)==EOF) break;
            //convert
            sx = ins1[0] - 'a' +1;
            sy = ins1[1] - '0';
            ex = ins2[0] - 'a' +1;
            ey = ins2[1] - '0';
            
            memset(flag, 0, sizeof(flag));
            bfs();
    }
    
    return 0;
}



